package com.study.shengsiyuan.example02;

import java.util.UUID;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class MyServerHandler extends SimpleChannelInboundHandler<String> {

	@Override
	protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
		System.out.println(ctx.channel().remoteAddress()+" , "+ msg );
		ChannelFuture cf =ctx.channel().writeAndFlush("from server : "+UUID.randomUUID());

	}


	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("---------channelActive");
		super.channelActive(ctx);
	}



	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		ctx.close();
	}
}
